home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
addres1a
/
addressm.frm
< prev
next >
Wrap
Text File
|
1999-09-15
|
4KB
|
147 lines
VERSION 5.00
Begin VB.Form AddressMain
Caption = "Address Book Example - PleX"
ClientHeight = 2595
ClientLeft = 165
ClientTop = 450
ClientWidth = 6795
LinkTopic = "Form1"
ScaleHeight = 2595
ScaleWidth = 6795
StartUpPosition = 2 'CenterScreen
Begin VB.ComboBox cmbContacts
Height = 360
Left = 240
Sorted = -1 'True
Style = 2 'Dropdown List
TabIndex = 1
Top = 600
Width = 2775
End
Begin VB.Frame Frame1
Caption = "Contacts!"
Height = 2535
Left = 0
TabIndex = 0
Top = 0
Width = 6735
Begin VB.TextBox txtPhone
Height = 285
Left = 240
TabIndex = 6
Top = 2040
Width = 2775
End
Begin VB.TextBox txtEmail
Height = 285
Left = 240
TabIndex = 4
Top = 1320
Width = 2775
End
Begin VB.Label Label3
Caption = "Phone Number:"
Height = 255
Left = 240
TabIndex = 5
Top = 1800
Width = 1935
End
Begin VB.Label Label2
Caption = "Email:"
Height = 255
Left = 240
TabIndex = 3
Top = 1080
Width = 615
End
Begin VB.Label Label1
Caption = "Name:"
Height = 255
Left = 240
TabIndex = 2
Top = 360
Width = 855
End
End
Begin VB.Menu mnuFile
Caption = "&File"
Begin VB.Menu mnuNewContact
Caption = "&New Contact"
End
Begin VB.Menu mnuSep
Caption = "-"
End
Begin VB.Menu mnuExit
Caption = "E&xit"
End
End
End
Attribute VB_Name = "AddressMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim db As Database
Dim rs As Recordset
Dim rsemail As Recordset
Dim rsphone As Recordset
Private Sub cmbContacts_Click()
On Error Resume Next
Set db = OpenDatabase(App.Path + "\" + "connections.mdb")
Set rsemail = db.OpenRecordset("SELECT contacts.email From contacts WHERE contacts.name = " + Chr$(34) + cmbContacts.Text + Chr$(34) + ";")
Set rsphone = db.OpenRecordset("SELECT contacts.phone From contacts WHERE contacts.name = " + Chr$(34) + cmbContacts.Text + Chr$(34) + ";")
rsemail.MoveFirst
txtEmail.Text = rsemail.Fields("email")
txtPhone.Text = rsphone.Fields("phone")
db.Close
End Sub
Private Sub Form_Load()
Set db = OpenDatabase(App.Path + "\" + "connections.mdb")
Set rs = db.OpenRecordset("Contacts")
rs.MoveFirst
Do Until rs.EOF
cmbContacts.AddItem rs.Fields("Name")
rs.MoveNext
Loop
db.Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
Close
End Sub
Private Sub mnuExit_Click()
Close 'this makes sure every thing is closed, just incase the
'db object didnt close properly for some reason or another
Unload Me
End Sub
Private Sub mnuNewContact_Click()
Load AddNew
AddNew.Show
End Sub